home *** CD-ROM | disk | FTP | other *** search
GW-BASIC | 1984-04-24 | 7.1 KB | 171 lines |
- 10 REM ******************** WARI.BAS **************************
- 11 KEY OFF:CLS:PRINT "Wari was modified for the IBM PC from the book:
- 12 PRINT "`BASIC Programs for the TRS-80'
- 15 PRINT "Copyright 1979 by Tom Rugg and Phil Feldman":PRINT
- 20 PRINT "Do you wish to read the instructions?"
- 21 Y$=INKEY$
- 22 IF Y$="" THEN 21
- 30 IF Y$="Y" OR Y$="y" THEN GOSUB 3000
- 120 DEFINT A-D,J-T,W-Y:J=1:K=1:Q=14:P=13:F=50:D=12
- 130 DIM T(14),Y(14),W(14),V(6),E(14),B(14),M(10)
- 140 RANDOMIZE INT(VAL(RIGHT$(TIME$,2))):ZB=RND:ZB=ZB/Q:ZA=0.25-ZB:GOSUB 750
- 150 FOR J=1 TO D:B(J)=4:NEXT:B(P)=0:B(Q)=0:M(N)=0:GOSUB 1200:GOSUB 900
- 160 GOSUB 990:INPUT "WANT TO GO FIRST";R$
- 170 GOSUB 990:PRINT D$:R$=LEFT$(R$,1):IF R$="Y" THEN 250
- 180 IF R$<>"N" THEN 160
- 190 GOSUB 1050:PRINT D$;D$;D$;:GOSUB 1050:PRINT "THINKING";:GOSUB 510
- 195 IF M<1 THEN 2000
- 200 GOSUB 1050:PRINT D$;:GOSUB 1050:PRINT "MY MOVE IS";M
- 210 FOR J=1 TO Q:T(J)=B(J):NEXT:GOSUB 350
- 220 FOR J=1 TO Q:B(J)=T(J):NEXT:GOSUB 900
- 230 IF B(Q)<24 THEN 250
- 240 GOSUB 1050:PRINT "I WIN!";D$:GOTO 810
- 250 GOSUB 990:PRINT D$;D$:GOSUB 990:PRINT "YOUR MOVE ";
- 252 R$=INKEY$
- 254 IF R$="" GOTO 252
- 260 M=INT(VAL(R$)):IF M>6 OR M<1 THEN 330
- 265 PRINT R$;
- 270 FOR J=1 TO Q:T(J)=B(J):NEXT
- 280 GOSUB 350:IF M<0 THEN 330
- 290 FOR J=1 TO Q:B(J)=T(J):NEXT
- 300 MN=MN+1:GOSUB 900
- 310 IF B(P)<24 THEN 190
- 320 GOSUB 1050:PRINT "YOU WIN!";D$:GOTO 810
- 330 LOCATE 13,20:PRINT " ILLEGAL ";:FOR J=1 TO 3000:NEXT:GOTO 250
- 350 IF T(M)=0 THEN M=-1:RETURN
- 360 R$="H":IF M>6 THEN R$="C":GOTO 380
- 370 FOR J=1 TO Q:Y(J)=T(J):NEXT :GOTO 400
- 380 FOR J=1 TO 6:Y(J)=T(J+6):Y(J+6)=T(J):NEXT
- 390 Y(P)=T(Q):Y(Q)=T(P):M=M-6
- 400 C=M:N=Y(C):FOR J=1 TO N:C=C+1
- 410 IF C=P THEN C=1
- 420 IF C=M THEN C=C+1:GOTO 410
- 430 Y(C)=Y(C)+1:NEXT :Y(M)=0:L=C
- 440 IF L<7 OR Y(L)>3 OR Y(L)<2 THEN 460
- 450 Y(P)=Y(P)+Y(L):Y(L)=0:L=L-1:GOTO 440
- 460 S=0:FOR J =7 TO D:S=S+Y(J):NEXT
- 470 IF S=0 THEN M=-2:RETURN
- 480 IF R$="H" THEN FOR J=1 TO Q:T(J)=Y(J):NEXT :RETURN
- 490 FOR J=1 TO 6:T(J)=Y(J+6):T(J+6)=Y(J):NEXT
- 500 T(Q)=Y(P):T(P)=Y(Q):RETURN
- 510 FOR A=1 TO 6:M=A+6:IF B(M)=0 THEN E(A)=-F:GOTO 690
- 530 FOR J=1 TO Q:T(J)=B(J):NEXT :GOSUB 350
- 540 IF M<0 THEN E(A)=-F:GOTO 690
- 550 IF T(Q)>23 THEN M=A+6:RETURN
- 560 FOR J=1 TO Q:W(J)=T(J):NEXT :FOR K=1 TO 6
- 570 IF T(K)=0 THEN V(K)=F:GOTO 670
- 580 FOR J=1 TO Q:T(J)=W(J):NEXT :M=K:GOSUB 350
- 590 IF M=0 THEN V(K)=F:GOTO 670
- 600 FA=0:FB=0:FC=0:FD=0:FOR J=7 TO D
- 610 FB=FB+T(J):IF T(J)>0 THEN FA=FA+1
- 620 IF T(J)<3 THEN FC=FC+1
- 630 IF T(J)>FD THEN FD=T(J)
- 640 NEXT :FE=FB:FOR J=1 TO 6:FE=FE+T(J):NEXT
- 650 FA=FA/6:FD=1-FD/FB:FC=1-FC/6:FB=FB/FE
- 660 V(K)=ZA*(FA+FB)+ZB*(FC+FD)+T(Q)+B(P)-B(Q)-T(P)
- 670 NEXT :E(A)=F:FOR J=1 TO 6:IF V(J)<E(A) THEN E(A)=V(J)
- 680 NEXT
- 690 PRINT ".";:NEXT :M=0:FA=-F:FOR J=1 TO 6
- 700 IF E(J)>FA THEN FA=E(J):M=J+6
- 710 NEXT :RETURN
- 750 A$="KEYTHENTHENTHENTHENTHEN<0xCB!>THENTHENTHENTHENTHEN<0xCB!>THENTHENTHENTHENTHEN<0xCB!>THENTHENTHENTHENTHEN<0xCB!>THENTHENTHENTHENTHEN<0xCB!>THENTHENTHENTHENTHENCLOSE"
- 760 B$="OPEN":FOR J=1 TO 6:B$=B$+" "+"OPEN":NEXT
- 770 C$="TOTHENTHENTHENTHENTHENTAB(THENTHENTHENTHENTHENTAB(THENTHENTHENTHENTHENTAB(THENTHENTHENTHENTHENTAB(THENTHENTHENTHENTHENTAB(THENTHENTHENTHENTHENRANDOMIZE"
- 780 E$="SCREENTHENTHENTHENTHENTHENLOCATETHENTHENTHENTHENTHENLOCATETHENTHENTHENTHENTHENLOCATETHENTHENTHENTHENTHENLOCATETHENTHENTHENTHENTHENLOCATETHENTHENTHENTHENTHENLOAD"
- 790 D$=" ":FOR J=1 TO 5:D$=D$+D$:NEXT :RETURN
- 810 PRINT "GOOD GAME!"
- 820 INPUT "WANT TO PLAY AGAIN";R$
- 850 R$=LEFT$(R$,1):IF R$="Y" THEN 120
- 860 IF R$<>"N" THEN 820
- 870 PRINT :PRINT "SEE YOU LATTER"
- 880 END
- 900 FOR J=0 TO 5
- 910 LOCATE 6,3+J*6:PRINT B(12-J);
- 920 IF B(12-J)=0 THEN GOSUB 1100
- 930 NEXT :LOCATE 6,47:PRINT "COMPUTER ";B(Q);
- 940 FOR J=0 TO 5
- 950 LOCATE 9,3+J*6:PRINT B(J+1);:IF B(J+1)=0 THEN GOSUB 1100
- 960 NEXT :LOCATE 9,52:PRINT "YOU ";B(P);:RETURN
- 990 LOCATE 13,1:PRINT " ";:RETURN
- 1050 LOCATE 14,1:PRINT " ";:RETURN
- 1100 PRINT CHR$(29);" ";:RETURN
- 1200 CLS:PRINT TAB(30);"W A R I"
- 1220 PRINT TAB(14);"COMPUTER"
- 1230 FOR J=0 TO 5:PRINT TAB(6*J+2);12-J;:NEXT
- 1240 LOCATE 4,1:PRINT A$;TAB(50);"CAPTURED"
- 1250 PRINT B$:PRINT B$:PRINT C$
- 1252 PRINT B$:PRINT B$:PRINT E$
- 1260 FOR J=0 TO 5:PRINT TAB(6*J+2);J+1;:NEXT
- 1270 PRINT :PRINT TAB(17);"YOU":RETURN
- 2000 PRINT "NO LEGAL MOVES.":GOTO 820
- 3000 CLS:LOCATE 1,36:PRINT "W A R I"
- 3001 PRINT
- 3002 PRINT "PURPOSE"
- 3003 PRINT
- 3004 PRINT " Wari is an old game with roots that are even older. Its origins
- 3005 PRINT "go back thousands of years to a variety of other similar games,
- 3006 PRINT "all classified as being members of the Mancala family. Other
- 3007 PRINT "variations are Awari, Oware, Pallanguli, Kalah, and countless
- 3008 PRINT "other offshoots.
- 3009 PRINT " The program matches you against the computer. You are
- 3010 PRINT "probably going to loose a few games before you win one-the
- 3011 PRINT "computer plays a pretty good game. This may hurt your ego a
- 3012 PRINT "little bit, since Wari is purely a skill game (like chess or checkers).
- 3013 PRINT "There is no element of luck involved, as would be the case with
- 3014 PRINT "backgammon, for example. When you loose, it's because you were
- 3015 PRINT "outplayed.
- 3016 LOCATE 24,1:PRINT "Press any key to continue";
- 3017 Y$=INKEY$
- 3018 IF Y$="" THEN 3017
- 3019 CLS:PRINT "HOW TO USE IT"
- 3020 PRINT
- 3021 PRINT " When you start the program, the first thing it does is display the Wari board
- 3022 PRINT "and ask you if you want to go first. The board is made up of twelve squares in
- 3023 PRINT "in two rows of six. Your side is the bottom side, numbered one through six
- 3024 PRINT "from left to right. The computers side is on the top, numbered seven through
- 3025 PRINT "twelve from right to left.
- 3026 PRINT " At the start of the game, each square has four `stones' in it. There is no
- 3027 PRINT "way to differentiate between your stones and the computer's. They all look
- 3028 PRINT "alike and will move from one side to the other during the course of play.
- 3029 PRINT " The first player `picks up' all the stones in one of the squares on his side
- 3030 PRINT "of the board and `drops them', one to a square, starting with the next highest
- 3031 PRINT "numbered square. The stones continue to be dropped consecutively in each
- 3032 PRINT "continuing over onto the opponent's side if necessary (after square 12 comes
- 3033 PRINT "square number 1 again).
- 3034 PRINT " If the last stone is dropped onto the opponent's side and leaves a total of
- 3035 PRINT "either two or three stones in that square, these stones are captured by the
- 3036 PRINT "player who moved, and removed from the board. Also, if the next-to-the last
- 3037 PRINT "square in which a stone was dropped meets the same conditions (on the
- 3038 PRINT "opponent's side with two or three stones), its stones are also captured. This
- 3039 PRINT "continues backwards until the string of consecutive squares of two or three on
- 3040 PRINT "the opponent's side is broken.
- 3041 LOCATE 24,1:PRINT "Press any key to continue";
- 3042 A$=INKEY$
- 3043 IF A$="" THEN 3042
- 3044 CLS:PRINT " Regardless of whether any captures are made, play alternates back and forth,
- 3045 PRINT "between the two players.
- 3046 PRINT " The object of the game is to be the first player to capture tyenty-four or
- 3047 PRINT "more stones. That's half of the forty-eight stones that are on the board at
- 3048 PRINT "beginning of the game.
- 3049 PRINT " There are a few special rules to cover some situations that can come up in
- 3050 PRINT "game. It is not legal to capture all the stones on the opponent's side of the
- 3051 PRINT "board, since this would leave the opponent with no moves on his next turn. By
- 3052 PRINT "the same token, when your opponent has no stones on his side (because he had
- 3053 PRINT "to move his last one to your side on his turn), you have to make a move that
- 3054 PRINT "gives him at least one stone to move on his next turn, if possible. If you
- 3055 PRINT "cannot make such a move, the game is over and counted as a draw.
- 3056 PRINT " During the course of the game, it's possible for a square to accumulate
- 3057 PRINT "twelve or more stones in it. Moving from such a square causes stones to be
- 3058 PRINT "distributed all the way around the board. When this happens, the square from
- 3059 PRINT "which the move was made is skipped over. So, the square moved from is always
- 3060 PRINT "left empty.
- 3061 PRINT " It takes the computer anywhere from five seconds to about forty seconds to
- 3062 PRINT "make a move, depending on the complexity of the board position (Interperter
- 3063 PRINT "BASIC only). The word `THINKING' is displayed during this time, and a period
- 3064 PRINT "is added to it as each possible move is evaluated in sequence.
- 3065 PRINT TAB(37) "- END -"
- 3066 LOCATE 24,1:PRINT "Press any key to continue";
- 3067 Y$=INKEY$
- 3068 IF Y$="" THEN 3066
- 3069 RETURN
-